import 'package:json_annotation/json_annotation.dart';

part 'identify_id_card.g.dart';

@JsonSerializable()
class IdentifyIDCard extends Object {
  @JsonKey(name: 'log_id')
  int logId;

  @JsonKey(name: 'direction')
  int direction;

  @JsonKey(name: 'image_status')
  String imageStatus;

  @JsonKey(name: 'photo')
  String photo;

  @JsonKey(name: 'photo_location')
  BDLocation photoLocation;

  @JsonKey(name: 'words_result')
  IDCard wordsResult;

  @JsonKey(name: 'words_result_num')
  int wordsResultNum;

  IdentifyIDCard(
    this.logId,
    this.direction,
    this.imageStatus,
    this.photo,
    this.photoLocation,
    this.wordsResult,
    this.wordsResultNum,
  );

  factory IdentifyIDCard.fromJson(Map<String, dynamic> srcJson) => _$IdentifyIDCardFromJson(srcJson);

  Map<String, dynamic> toJson() => _$IdentifyIDCardToJson(this);
}

@JsonSerializable()
class IDCard extends Object {
  @JsonKey(name: '住址')
  BDData address;

  @JsonKey(name: '公民身份号码')
  BDData idNumber;

  @JsonKey(name: '出生')
  BDData born;

  @JsonKey(name: '姓名')
  BDData name;

  @JsonKey(name: '性别')
  BDData sex;

  @JsonKey(name: '民族')
  BDData national;

  @JsonKey(name: '签发日期')
  BDData issueTime;

  @JsonKey(name: '失效日期')
  BDData expiryTime;

  @JsonKey(name: '签发机关')
  BDData issueAuthority;

  IDCard();

  factory IDCard.fromJson(Map<String, dynamic> srcJson) => _$IDCardFromJson(srcJson);

  Map<String, dynamic> toJson() => _$IDCardToJson(this);
}

@JsonSerializable()
class BDData extends Object {
  @JsonKey(name: 'location')
  BDLocation location;

  @JsonKey(name: 'words')
  String words;

  BDData(
    this.location,
    this.words,
  );

  factory BDData.fromJson(Map<String, dynamic> srcJson) => _$BDDataFromJson(srcJson);

  Map<String, dynamic> toJson() => _$BDDataToJson(this);
}

@JsonSerializable()
class BDLocation extends Object {
  @JsonKey(name: 'left')
  int left;

  @JsonKey(name: 'top')
  int top;

  @JsonKey(name: 'width')
  int width;

  @JsonKey(name: 'height')
  int height;

  BDLocation(
    this.left,
    this.top,
    this.width,
    this.height,
  );

  factory BDLocation.fromJson(Map<String, dynamic> srcJson) => _$BDLocationFromJson(srcJson);

  Map<String, dynamic> toJson() => _$BDLocationToJson(this);
}
